
public class DormitoryAssignment {
    public static void main(String[] args) {
        // 准备数据，假设有10个学生，宿舍容量为4人
        double[][] data = new double[][] {
                {1, 0, 1, 0, 1, 0, 7, 23},
                {0, 1, 0, 1, 0, 1, 6, 22},
                {1, 0, 1, 0, 0, 1, 8, 24},
                {0, 1, 0, 1, 1, 0, 7, 21},
                {1, 0, 1, 0, 1, 0, 6, 22},
                {0, 1, 0, 1, 0, 1, 8, 23},
                {1, 0, 1, 0, 0, 1, 7, 21},
                {0, 1, 0, 1, 1, 0, 6, 24},
                {1, 0, 1, 0, 1, 0, 8, 22},
                {0, 1, 0, 1, 0, 1, 7, 23}
        };

        // 簇的个数为10/4=3，最大迭代次数为100
        //KMeans kmeans = new KMeans(4, 100, data);
        //kmeans.run();

        // 输出宿舍分配结果
        //int[] assignments = kmeans.getAssignments();
//        for (int i = 0; i < assignments.length; i++) {
//            System.out.println("Student " + (i + 1) + " is assigned to dormitory " + (assignments[i] + 1));
//        }
    }
}